<script src="../../../../Desktop/server/server.js"></script>
<template>
    <div id="content">

     


        <div class="registr">

            <input id="Id" style="margin-top:22em;" type="text" placeholder="学号：" v-model="id"><br><br>
            <input id="Pw"type="password" placeholder="密码：" v-model="Pw"><br><br>
            <input id="xingming" type="xingming" placeholder="姓名：" v-model="user"><br><br>
            <input type="button" value="注册" @click="registr">

        </div>



    </div>
</template>

<script>
    import axios from 'axios'
    import {mapMutations} from "vuex"

    export default {
        name: 'app',
        data () {

            return {
                id: "",
                Pw: "",
                user: "",
            }
        },
        methods: {
            ...mapMutations([
                'changeBtn' // 映射 this.increment() 为 this.$store.commit('increment')
            ]),
            registr: function() {
                var params = new URLSearchParams();
                params.append('id',this.id );
                params.append('Pw',this.Pw );
                params.append('user',this.user );
                var _this = this
                axios.post('/users/registr',params).then(function (res) {
                    if(res.data.result){
                        console.log(res.data.result);
                        _this.$router.push({path:'/my/my_1',query:{username:res.data.username}})
                        _this.changeBtn();
                    }else{
                        alert("404")
                    }
                }).catch(function (err) {
                    console.log(err);
                })
                this.$store.commit("changeStyle",4);
            }



        },


    }
</script>

<style scoped>
    #content{


    }

    .registr{

        width: 95%;

        margin: 0 auto;

    }


</style>